package cn.tedu.ivos3.repair.controller;

import cn.tedu.ivos3.base.response.JsonResult;
import cn.tedu.ivos3.repair.pojo.dto.RepairQuery;
import cn.tedu.ivos3.repair.pojo.dto.RepairSaveParam;
import cn.tedu.ivos3.repair.pojo.vo.RepairVO;
import cn.tedu.ivos3.repair.service.RepairService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/repair")
public class RepairController {
    @Autowired
    RepairService repairService;

    @PostMapping("save")
    public JsonResult saveVehicle(RepairSaveParam repairSaveParam) {
        log.debug("新增/编辑车辆维修信息，{}", repairSaveParam);
        repairService.saveVehicle(repairSaveParam);
        return JsonResult.ok();
    }

    @GetMapping("select")
    public JsonResult selectVehicle(RepairQuery repairQuery) {
        log.debug("查询车辆维修信息:{}", repairQuery);
        List<RepairVO> list = repairService.selectVehicle(repairQuery);
        return JsonResult.ok(list);
    }


    @PostMapping("delete/{id}")
    public JsonResult deleteVehicle(@PathVariable Long id) {
        log.debug("删除车辆维修信息：{}", id);
        repairService.deleteVehicle(id);
        return JsonResult.ok();
    }
}
